#ifndef _FILE_H
#define _FILE_H

#include "head.h"
#include "clist.h"
typedef gchar FOLDER;
typedef gchar FILE_NAME;
typedef enum _LANGUAGE_{CHINESE,ENGLISH}LANGUAGE;

#define FILE_NAME_LEN 30
/**
 * struct file_list - data file descriptor
 * 
 * @name:           file name
 * @newname:     if you modified group name ,we save the new name to here
 * @offset:           the offset of recoded start in data file
 * @info_nums:    amounts of information had been recoded in the data file
 * @col_nums:      the columns of one information
 * @columns:       all name strings of these columns
 * @modify:          in GtkCList clist_group,this data file has been add to which row?
 * @group_id:       information has been modified?
 * @next:              point to next data file
 */
struct file_list {
    FILE_NAME name[FILE_NAME_LEN];
    FILE_NAME newname[FILE_NAME_LEN];
    gint32 offset;
    gint info_nums;
    gint col_nums;
    gchar *columns;
    gint group_id;
    gboolean modify;
    struct file_list *next;
};

/**
 * struct file_ctrl - global file operate descriptor
 * @language:         the language of user set,default is chinese
 * @home:               home folder of program use
 * @config:              config file folder
 * @tmp:                  tmp file folder
 * @data:                 data file folder
 * @current:             data file name which current use
 * @cur_file:             point to current data file
 * @group_nums:     how many groups user create?default has one
 * @group:               all name of these groups
 * @modify:              if you add a group or rename the group name ,it will been set TRUE
 * @data_mod:          if you modified data file,it will been set TRUE;
 * @files:                  point to data file list
 */
struct file_ctrl {
	LANGUAGE language;
	FOLDER *home;
	FOLDER *config;
	FOLDER *tmp;
	FOLDER *data;
	FILE_NAME current[FILE_NAME_LEN];
	struct file_list *cur_file;
	gint group_nums;
	gchar *groups;
	gboolean modify;
	gboolean data_mod;
	struct file_list *files;
};

extern struct file_ctrl global_file;//defined in file.c

gboolean create_easyblog_folder(struct file_ctrl *global_file);
gboolean create_data_file(const gchar *path,const gchar *name);
gboolean read_data_file_info(struct file_list *file,const gchar *path);
gboolean read_config_file(struct file_ctrl *global_file);
gboolean create_tmp_file(struct file_ctrl *global_file);
gboolean show_all_group(struct file_ctrl *global_file,struct clist_struct *clist);
gboolean read_data_file_to_show(const gchar *path,
					struct file_ctrl *global_file,struct clist_struct *clist);
#endif //_FILE_H
